package com.smarthome.ipc.worker;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.smarthome.ipc.service.GetIpService;

@Service
public class IpcWorkerService {
	
	private Log LOGGER = LogFactory.getLog(getClass());
	
	@Resource
	private GetIpService getIp;
	
    @Scheduled(initialDelay = 10 * 1000, fixedRate = 30 * 1000)
    public void updateInternetIp() {
    	LOGGER.info("获取本机外网IP开始-------------------------->");
    	
    	try {
			getIp.synchrNetip();
		} catch (Exception e) {
			e.printStackTrace();
			LOGGER.error("获取本机外网IP异常："+e.getMessage());
		}
    	
    	LOGGER.info("获取本机外网IP结束---------30秒后执行---------->");
    }
}
